﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Model="clr-namespace:BingMapsWPFViewer.Model;assembly=BingMapsWPFViewer.Model"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:v="clr-namespace:BingMapsWPFViewer.Views"
        xmlns:f="http://bingmapswpfviewer.codeplex.com/Framework"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        x:Class="BingMapsWPFViewer.Views.EditLayerView"
        Title="Edit Layer"
        Icon="layers.png"
        Height="500"
        Width="600"
        WindowStartupLocation="CenterOwner"
        f:DialogCloser.DialogResult="{Binding DialogResult}">
    <Window.Resources>

        <v:LayerDataTemplateSelector x:Key="LayerDataTemplateSelector" />

    </Window.Resources>

    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="90" />
            <RowDefinition Height="*" />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>

        <!-- Layer Type & Name -->
        <Grid HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch"
              Grid.Row="0"
              Background="WhiteSmoke">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="80" />
            </Grid.ColumnDefinitions>

            <StackPanel Orientation="Horizontal"
                        Grid.Row="0"
                        Grid.Column="0"
                        Grid.ColumnSpan="3"
                        Margin="0">
                <TextBlock VerticalAlignment="Center"
                           FontSize="14"
                           FontStyle="Italic"
                           Text="{Binding CurrentLayer.LayerType}" />
                <TextBlock VerticalAlignment="Center"
                           FontSize="14"
                           FontStyle="Italic"
                           Text=" layer" />
            </StackPanel>

            <TextBlock FontWeight="Bold"
                       Grid.Row="1"
                       Grid.Column="0"
                       Margin="10"
                       VerticalAlignment="Center"
                       FontSize="14">Layer name</TextBlock>
            <TextBox Background="White"
                     Grid.Row="1"
                     Grid.Column="1"
                     HorizontalAlignment="Stretch"
                     Margin="0,10,0,10"
                     FontSize="14"
                     VerticalAlignment="Center"
                     Text="{Binding LayerName, Mode=TwoWay}"></TextBox>
            <Button Content="Generate"
                    Grid.Column="2"
                    Grid.Row="1"
                    Margin="5,0,10,0"
                    Command="{Binding GenerateDisplayNameCommand}"
                    Height="25"></Button>
        </Grid>

        <ContentPresenter Grid.Row="1"
                          Margin="5"
                          Content="{Binding CurrentLayer}"
                          ContentTemplateSelector="{StaticResource LayerDataTemplateSelector}">

        </ContentPresenter>


        <!-- Buttons -->
        <Button Content="{Binding SaveCaption}"
                Grid.Row="2"
                Grid.ColumnSpan="2"
                Width="100"
                Height="25"
                HorizontalAlignment="Right"
                Margin="0,0,0,10"
                Command="{Binding SaveLayerCommand}"
                IsEnabled="{Binding CurrentLayer.IsValid}" />
        <Button x:Name="btnClose"
                Content="{Binding CloseCaption}"
                Grid.Row="2"
                Width="100"
                Height="25"
                HorizontalAlignment="Left"
                Command="{Binding CloseCommand}"
                Margin="0,0,0,10"
                IsDefault="True" />

    </Grid>
</Window>
